home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6936 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: kelvin.physics.mun.ca!cdeacon
  2. From: cdeacon@kelvin.physics.mun.ca (Chris Deacon)
  3. Newsgroups: comp.lang.c
  4. Subject: Function wanted to evaluate string
  5. Date: 16 Feb 1996 13:22:32 GMT
  6. Organization: Physics Dept at Memorial University NF
  7. Distribution: world
  8. Message-ID: <4g20eo$623@coranto.ucs.mun.ca>
  9. Reply-To: cdeacon@kelvin.physics.mun.ca (Chris Deacon)
  10. NNTP-Posting-Host: kelvin.physics.mun.ca
  11. X-Newsreader: mxrn 6.18-30
  12.  
  13.  
  14. I want a function which will evaluate a string of numbers and
  15. arithmetic operators. That is, whwn I call
  16.   
  17. eval_func(2*5)
  18.  
  19.  a value of 10 will be returned.
  20.  
  21. Ideally, I'd like the code to be able to handle several operators
  22. in the string, so that
  23.  
  24. eval_func((3*5.7)/(2-.77)+4.5)
  25.  
  26. will be evaluated just as easily.
  27.  
  28. All suggestions gratefully appreciated..
  29.  
  30. Chris
  31. -- 
  32. +-----------------------------+-------------------------------------+ 
  33. | Christopher Deacon          |         (709) 737-7631              | 
  34. | Physics Department          |   cdeacon@kelvin.physics.mun.ca     !
  35. | Memorial University of Nfld | http://www.physics.mun.ca/~cdeacon  |
  36. +-----------------------------+-------------------------------------+
  37.  
  38.